<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed to change the Language/Country and region settings 
 #   Configuration Type - USER

 #   LanguageTag can be found from the below link
     "https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs"

 #   GeoLocationID can be found from the below link
     "https://docs.microsoft.com/en-us/windows/desktop/intl/table-of-geographical-locations"

 #   Windows related article: https://www.elevenforum.com/t/change-country-or-region-geographic-location-geoid-in-windows-11.4034/
#>

# Define variables for language tag and geo location ID (Hardcode in the below area)
$LanguageTag = "en-US"
$GeoLocationID = "244"

try {
    # Set the system culture
    Set-Culture -CultureInfo $LanguageTag
    Write-Host "System Culture set successfully"
} catch {
    Write-Error "Failed to set system culture: $_"
}

try {
    # Set the system locale
    Set-WinSystemLocale -SystemLocale $LanguageTag
    Write-Host "System Locale set successfully"
} catch {
    Write-Error "Failed to set system locale: $_"
}

# Check if the GeoLocationID is provided
if ($GeoLocationID -ne "") {
    try {
        # Change the Home location setting of the user
        Set-WinHomeLocation -GeoId $GeoLocationID
        Write-Host "GeoLocationID set successfully"
    } catch {
        Write-Error "Failed to set home location: $_"
    }
}

try {
    # Change the Windows Language setting for the user
    Set-WinUserLanguageList -LanguageList $LanguageTag -Force
    Write-Host "Windows Language setting for the user set successfully"
} catch {
    Write-Error "Failed to set user language list: $_"
}

try {
    # Set the UI language override for the user
    Set-WinUILanguageOverride -Language $LanguageTag
    Write-Host "UI language override for the user set successfully"
} catch {
    Write-Error "Failed to set UI language override: $_"
}